home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 1.6 KB | 54 lines | [TEXT/MPS ] |
- /*
- File: AYSThreadGlue.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- //
- // By defining this macro differently here, we get different results from our
- // header file AYSGlue.h. This macro causes the MakePBFunctionSleepable macro
- // make 'glue' functions, so that
- //
- // MakePBFunctionSleepable(FSOpen,ParamBlockRec)
- //
- // creates a new function
- //
- // OSErr FSOpenGlue(ParamBlockRec* pb, Boolean async) {
- // return FSOpen(pb, async);
- // };
- //
- // This glue function is useful with the Threads package, because with threads we
- // want to be able to call async functions from a thread, and have that thread
- // automatically put to sleep until the call completes. To do this, the
- // definition of the macro MakePBFunctionSleepable in the AYSGlue.h file does
- // the following:
- //
- // MakePBFunctionSleepable(FSOpen, ParamBlockRec)
- //
- // creates a new function
- //
- // OSErr FSOpenSleep(ParamBlockRec* pb) {
- // return TFSDispatchAsync((FNPBB) FSOpenFlue, (ParmBlkPtr) pb);
- // };
- //
- // Notice that this function includes the address of the glue function created by
- // the macro when the AYSGlue.cp file is compiled. And, by calling FSOpenSleep(),
- // the calling thread will be put to sleep until the call completes.
- //
- #define MakePBFunctionSleepable(function,ParamBlockType) \
- pascal OSErr name2(function,Glue)(ParamBlockType *pb, Boolean asyncFlag) { \
- return function(pb, asyncFlag); \
- };
-
- #pragma segment Main
-
- #include "AYSThreadGlue.h"
-
-